Skip to content

Conversation

@amol-
Copy link
Collaborator

@amol- amol- commented Mar 12, 2025

Intent

Second step toward supporting python interpreter version requirements in manifest.json generation.
This is a follow-up of #643 that adds support for the other two planned file formats.

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change

Approach

Continuing with small incremental PRs approach to add support for each new format keeping the review effort minimal.

Automated Tests

New tests were added for every function in the test_pyproject.py file.

Directions for Reviewers

This continues in the direction of building all the necessary blocks without exposing the feature to the end user until the very end. The PR is based on the #643 code, so it should be reviewed only once the other PR is merged as it will influence this one.

@github-actions
Copy link

github-actions bot commented Mar 12, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
4868 3621 74% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/pyproject.py 100% 🟢
TOTAL 100% 🟢

updated for commit: 576c9d4 by action🐍

@amol- amol- force-pushed the extract-setupcfg-pyversion-30404-30405 branch from 588e136 to 9e8a930 Compare March 13, 2025 11:46
@amol- amol- requested a review from sagerb March 13, 2025 13:58
@amol- amol- marked this pull request as ready for review March 13, 2025 14:06
elif metadata_file.name == ".python-version":
return parse_pyversion_python_requires
else:
return None
Copy link
Collaborator Author

@amol- amol- Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be done with a lookup table, but given the options aren't many I preferred to be explicit and avoid dynamic lookups which are harder to follow when debugging.

@amol- amol- self-assigned this Mar 13, 2025
Copy link
Contributor

@sagerb sagerb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is looking great. I provided a few small suggestions which I think will improve the code. Reach out when you are ready for another review.

The returned function takes a pathlib.Path and returns the parsed value.
"""
if metadata_file.name == "pyproject.toml":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always wondering if we should be comparing filenames with a case-insensitive comparison. When I looked, google's AI provided this, so I think this might be a good improvement here:

The pyproject.toml filename is generally treated as case-insensitive by most Python tools and systems. While the file system itself might be case-sensitive, tools that interact with pyproject.toml, such as pip, poetry, and build, typically perform case-insensitive matching when searching for the file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given

https://github.com/pypa/pip/blob/main/src/pip/_internal/req/req_install.py#L512-L514

and

https://github.com/pypa/pip/blob/main/src/pip/_internal/pyproject.py#L26-L27

I think it's fairly safe to assume that the filename is expected to be lowercase for pip too.

It's true that the PEP doesn't explicitly say that the filename must be case sensitive, but in every single place it explicitly write pyproject.toml lowercase, which I think it's safe to expect it means the filename is expected to always be lowercase and thus work in both case sensitive and case insensitive file systems.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks for considering my suggestion.

assert lookup_metadata_file(project_dir) == expectation


@pytest.mark.parametrize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe consider a comment describing this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one at line 58, do think it's not sufficiently informative?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry, I caught myself seeing that for a different test and suppressed my comment. This is fine.

Copy link
Contributor

@sagerb sagerb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for responding to my comments. I'm good with this now.

@amol- amol- merged commit e991f3d into main Mar 14, 2025
11 of 13 checks passed
@amol- amol- deleted the extract-setupcfg-pyversion-30404-30405 branch March 14, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants